package com.sokal.easycare.modules.kpoint.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import com.sokal.easycare.common.persistence.Page;
import com.sokal.easycare.common.service.CrudService;
import com.sokal.easycare.common.utils.StringUtils;
import com.sokal.easycare.common.utils.FastDFS.FastDFSClient;
import com.sokal.easycare.modules.kpoint.entity.KPointMain;
import com.sokal.easycare.modules.kpoint.dao.KPointMainDao;

/**
 * 体验店Service
 * @author lihaipei
 * @version 2017-03-18
 */
@Service
@Transactional(readOnly = true)
public class KPointMainService extends CrudService<KPointMainDao, KPointMain> {

	public KPointMain get(String id) {
		return super.get(id);
	}
	
	public List<KPointMain> findList(KPointMain kPointMain) {
		return super.findList(kPointMain);
	}
	
	public Page<KPointMain> findPage(Page<KPointMain> page, KPointMain kPointMain) {
		return super.findPage(page, kPointMain);
	}
	
	@Transactional(readOnly = false)
	public void save(MultipartFile storeFile, KPointMain kPointMain) {
		try {
			if (StringUtils.isNotBlank(storeFile.getOriginalFilename())) {
				kPointMain.setImageUrl(FastDFSClient.uploadFile(storeFile, storeFile.getOriginalFilename()));
			}
			super.save(kPointMain);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@Transactional(readOnly = false)
	public void delete(KPointMain kPointMain) {
		super.delete(kPointMain);
	}
	
}